package aufgaben170311;

import java.util.Vector;
import java.io.*;

public class StreamIO02 {

	/**
	 * @param args
	 */

	public static void main(String[] args) throws Exception {
		// Vector schreiben
		Vector<Adresse> adressVector = new Vector<Adresse>();

		adressVector.add(new Adresse("Bahnhofstr. 21", "28816", "Stuhr"));
		adressVector
				.add(new Adresse("Liebensteiner Str. 30", "28205", "Bremen"));
		adressVector.add(new Adresse("C. Es Tudons, 18", "07590",
				"Cala Ratjada"));

		ObjectOutputStream oos = null;

		oos = new ObjectOutputStream(new FileOutputStream("adressen.dat"));
		oos.writeObject(adressVector);
		oos.close();

		// Vector einlesen
		Vector<Adresse> adressVectorIn = new Vector<Adresse>();
		ObjectInputStream ois = null;
		ois = new ObjectInputStream(new FileInputStream("adressen.dat"));
		adressVectorIn = (Vector<Adresse>) ois.readObject();
		//for (int i = 0; i < adressVectorIn.size(); i++)
			System.out.println(adressVectorIn);
		ois.close();
	}
}
